﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using GameEngine.Entities;

namespace GameEngine.EntityComponents
{
    public class CollidableComponent : IEntityComponent
    {
        private AbstractEntity entity;
        public Rectangle bottom {get; private set;}
        public Rectangle top { get; private set; }
        public Rectangle right { get; private set; }
        public Rectangle left { get; private set; }
        private int singleImageWidth = 60;
        private int singleImageHeight = 96;
        public float boundingBoxSize;

        public CollidableComponent(AbstractEntity entity, float boundingBoxSize)
        {
            this.entity = entity;
            this.boundingBoxSize = boundingBoxSize;
            Initialize();
        }

        public void Update(GameTime gameTime)
        {
            top = new Rectangle((int)entity.position.X, (int)entity.position.Y, singleImageWidth,
                        (int)(singleImageHeight - (singleImageHeight * (1 - boundingBoxSize))));

            bottom = new Rectangle((int)entity.position.X, (int)(entity.position.Y + (singleImageHeight * (1 - boundingBoxSize))),
                        singleImageWidth, (int)(singleImageHeight - (singleImageHeight * (1 - boundingBoxSize))));

            right = new Rectangle((int)(entity.position.X + (singleImageWidth * (1 - boundingBoxSize))), (int)entity.position.Y,
                        (int)(singleImageWidth - (singleImageWidth * (1 - boundingBoxSize))), singleImageHeight);

            left = new Rectangle((int)entity.position.X, (int)entity.position.Y, (int)(singleImageWidth - (singleImageWidth * (1 - boundingBoxSize))),
                        singleImageHeight);
        }

        private void Initialize()
        { }

        public void CollideWith(AbstractEntity target, bool isX, bool isY)
        { }
    }
}
